/*
LESS variables are information about icon's compiled state, stored under its original file name

.icon-home {
  width: @icon-home-width;
}

The large array-like variables contain all information about a single icon
@icon-home: x y offset_x offset_y width height total_width total_height image_path name;

At the bottom of this section, we provide information about the spritesheet itself
@spritesheet: width height image @spritesheet-sprites;
*/
@aa-name: 'aa';
@aa-x: 0px;
@aa-y: 0px;
@aa-offset-x: 0px;
@aa-offset-y: 0px;
@aa-width: 48px;
@aa-height: 48px;
@aa-total-width: 144px;
@aa-total-height: 144px;
@aa-image: 'sprite.png';
@aa: 0px 0px 0px 0px 48px 48px 144px 144px 'sprite.png' 'aa';
@bb-name: 'bb';
@bb-x: 48px;
@bb-y: 0px;
@bb-offset-x: -48px;
@bb-offset-y: 0px;
@bb-width: 48px;
@bb-height: 48px;
@bb-total-width: 144px;
@bb-total-height: 144px;
@bb-image: 'sprite.png';
@bb: 48px 0px -48px 0px 48px 48px 144px 144px 'sprite.png' 'bb';
@cc-name: 'cc';
@cc-x: 0px;
@cc-y: 48px;
@cc-offset-x: 0px;
@cc-offset-y: -48px;
@cc-width: 48px;
@cc-height: 48px;
@cc-total-width: 144px;
@cc-total-height: 144px;
@cc-image: 'sprite.png';
@cc: 0px 48px 0px -48px 48px 48px 144px 144px 'sprite.png' 'cc';
@dd-name: 'dd';
@dd-x: 48px;
@dd-y: 48px;
@dd-offset-x: -48px;
@dd-offset-y: -48px;
@dd-width: 48px;
@dd-height: 48px;
@dd-total-width: 144px;
@dd-total-height: 144px;
@dd-image: 'sprite.png';
@dd: 48px 48px -48px -48px 48px 48px 144px 144px 'sprite.png' 'dd';
@ee-name: 'ee';
@ee-x: 96px;
@ee-y: 0px;
@ee-offset-x: -96px;
@ee-offset-y: 0px;
@ee-width: 48px;
@ee-height: 48px;
@ee-total-width: 144px;
@ee-total-height: 144px;
@ee-image: 'sprite.png';
@ee: 96px 0px -96px 0px 48px 48px 144px 144px 'sprite.png' 'ee';
@ff-name: 'ff';
@ff-x: 96px;
@ff-y: 48px;
@ff-offset-x: -96px;
@ff-offset-y: -48px;
@ff-width: 48px;
@ff-height: 48px;
@ff-total-width: 144px;
@ff-total-height: 144px;
@ff-image: 'sprite.png';
@ff: 96px 48px -96px -48px 48px 48px 144px 144px 'sprite.png' 'ff';
@gg-name: 'gg';
@gg-x: 48px;
@gg-y: 96px;
@gg-offset-x: -48px;
@gg-offset-y: -96px;
@gg-width: 47px;
@gg-height: 48px;
@gg-total-width: 144px;
@gg-total-height: 144px;
@gg-image: 'sprite.png';
@gg: 48px 96px -48px -96px 47px 48px 144px 144px 'sprite.png' 'gg';
@hh-name: 'hh';
@hh-x: 0px;
@hh-y: 96px;
@hh-offset-x: 0px;
@hh-offset-y: -96px;
@hh-width: 48px;
@hh-height: 48px;
@hh-total-width: 144px;
@hh-total-height: 144px;
@hh-image: 'sprite.png';
@hh: 0px 96px 0px -96px 48px 48px 144px 144px 'sprite.png' 'hh';
@spritesheet-width: 144px;
@spritesheet-height: 144px;
@spritesheet-image: 'sprite.png';
@spritesheet-sprites: @aa @bb @cc @dd @ee @ff @gg @hh;
@spritesheet: 144px 144px 'sprite.png' @spritesheet-sprites;

/*
The provided classes are intended to be used with the array-like variables

.icon-home {
  .sprite-width(@icon-home);
}
.icon-email {
  .sprite(@icon-email);
}

Example usage in HTML:

`display: block` sprite:
<div class="icon-home"></div>

To change `display` (e.g. `display: inline-block;`), we suggest using a common CSS class:

// CSS
.icon {
  display: inline-block;
}

// HTML
<i class="icon icon-home"></i>
*/
.sprite-width(@sprite) {
  width: extract(@sprite, 5);
}

.sprite-height(@sprite) {
  height: extract(@sprite, 6);
}

.sprite-position(@sprite) {
  @sprite-offset-x: extract(@sprite, 3);
  @sprite-offset-y: extract(@sprite, 4);
  background-position: @sprite-offset-x @sprite-offset-y;
}

.sprite-image(@sprite) {
  @sprite-image: extract(@sprite, 9);
  background-image: e(%('url(%a)', e(@sprite-image)));
}

.sprite(@sprite) {
  .sprite-image(@sprite);
  .sprite-position(@sprite);
  .sprite-width(@sprite);
  .sprite-height(@sprite);
}

/*
The `.sprites` mixin generates identical output to the CSS template
  but can be overridden inside of LESS

This must be run when you have at least 2 sprites.
  If run with a single sprite, then there will be reference errors.

.sprites(@spritesheet-sprites);
*/
.sprites(@sprites, @i: 1) when (@i <= length(@sprites)) {
  @sprite: extract(@sprites, @i);
  @sprite-name: e(extract(@sprite, 10));
  .@{sprite-name} {
    .sprite(@sprite);
  }
  .sprites(@sprites, @i + 1);
}
